﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Practices.EnterpriseLibrary.Validation.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration.Design;
using Microsoft.Practices.EnterpriseLibrary.Validation;
using System.Configuration;

namespace AsNum.Common.EntLib.Validation.CustomValidator.Configuration {
    [ResourceDescription ( typeof ( CustomValidatorReason ) , "NotNullOrEmptyValidatorDescription" )]
    [ResourceDisplayName ( typeof ( CustomValidatorReason ) , "NotNullOrEmptyValidatorName" )]
    public class NotNullOrEmptyValidatorData : ValueValidatorData {

        [ConfigurationProperty ( "Trim" )]
        public bool Trim {
            get {
                return ( bool )this["Trim"];
            }
            set {
                this["Trim"] = value;

            }
        }

        public NotNullOrEmptyValidatorData() {
            this.Type = typeof ( NotNullOrEmptyValidator );
        }

        public NotNullOrEmptyValidatorData(string name)
            : base ( name , typeof ( NotNullOrEmptyValidator ) ) {
        }

        protected override Validator DoCreateValidator(Type targetType) {
            return new NotNullOrEmptyValidator ( this.Negated , this.MessageTemplate , this.Tag , this.Trim );
        }
    }
}
